package com.yesep.learn.design.structural.facade;

import com.yesep.learn.design.common.pojo.*;

public class ComputerFacade {
    private final CPUComponent cpu;
    private final RAMComponent memory;
    private final StorageComponent hard;

    public ComputerFacade(CPUComponent cpu, RAMComponent memory, StorageComponent hard) {
        this.cpu = cpu;
        this.memory = memory;
        this.hard = hard;
    }

    public void startComputer() {
        cpu.start();
        memory.load(100, (byte) 1);
        byte[] buffer = hard.read(2048, 1024);
        cpu.execute("load operating system");
    }

    public void shutdownComputer() {
        cpu.freeze();
        cpu.execute("halt");
    }

    public void executeCommand(String command) {
        cpu.execute(command);
    }
}
